FROM docker.io/openjdk:17
MAINTAINER emms "2061976943@qq.com"

ARG EMMS_STORE_SERVICE_VERSION=1.0
ARG EMMS_STORE_SERVICE_DIR="emms-user-service"
ARG EMMS_STORE_SERVICE_PACKAGE="emms-user-service-$EMMS_STORE_SERVICE_VERSION.jar"
ARG EMMS_STORE_SERVICE_PROGRAM="emms-user-service.jar"

# set environment
ENV BASE_DIR="/home/EMMS/${EMMS_STORE_SERVICE_DIR}" \
    CLASSPATH=".:/home/EMMS/${EMMS_STORE_SERVICE_DIR}/conf:$CLASSPATH" \
    JAVA_HOME="/usr/java/openjdk-17" \
    JAVA="/usr/java/openjdk-17/bin/java" \
    JAVA_OPT_EXT="${JAVA_OPT_EXT}" \
    TIME_ZONE="Asia/Shanghai"

WORKDIR $BASE_DIR

ADD ./target/$EMMS_STORE_SERVICE_PACKAGE target/$EMMS_STORE_SERVICE_PACKAGE
RUN ln -snf /usr/share/zoneinfo/$TIME_ZONE /etc/localtime && echo $TIME_ZONE > /etc/timezone

ADD ../docker_file/user/bin/docker-startup.sh bin/docker-startup.sh
ADD ../docker_file/user/conf/bootstrap.yaml conf/bootstrap.yml
ADD ../docker_file/user/conf/logging-config.xml conf/logging-config.xml
RUN mkdir -p init.d

# set startup log dir
RUN mkdir -p logs \
        && cd logs \
        && touch start.out \
        && ln -sf /dev/stdout start.out \
        && ln -sf /dev/stderr start.out
RUN chmod +x bin/docker-startup.sh

EXPOSE 8098
ENTRYPOINT ["bin/docker-startup.sh"]